<!-- 个人中心：支持装修 -->
<template>
	<s-layout title="我的" tabbar="/pages/index/user" navbar="custom" :bgStyle="template.page"
		:navbarStyle="template.navigationBar" onShareAppMessage>
		<s-block v-for="(item, index) in template.components" :key="index" :styles="item.property.style">
			<s-block-item v-if="index != template.components.length-1 && index != template.components.length-2 "
				:type="item.id" :data="item.property" :styles="item.property.style" />
		</s-block>

		<s-block v-if="isstemUserFlag" :styles="template.components[template.components.length-2].property.style">

			<s-block-item :type="template.components[template.components.length-2].id"
				:data="template.components[template.components.length-2].property"
				:styles="template.components[template.components.length-2].property.style" />
		</s-block>

		<s-block v-if="!state.isauthentication"
			:styles="template.components[template.components.length-1].property.style">

			<navigator url="plugin://rs-plugin/info-regist">
				<s-block-item :type="template.components[template.components.length-1].id"
					:data="template.components[template.components.length-1].property"
					:styles="template.components[template.components.length-1].property.style" />
			</navigator>

		</s-block>

	</s-layout>
</template>

<script setup>
	import {
		computed,
		reactive,
		onMounted
	} from 'vue';
	import {
		onShow,
		onPageScroll,
		onPullDownRefresh
	} from '@dcloudio/uni-app';
	import sheep from '@/sheep';
	import AuthUtil from '@/sheep/api/member/auth';

	// 隐藏原生tabBar
	uni.hideTabBar();

	const template = computed(() => sheep.$store('app').template.user);
	const isLogin = computed(() => sheep.$store('user').isLogin);
	const plugin = requirePlugin("rs-plugin"); // 引入插件
	const isstemUserFlag = computed(() => sheep.$store('user').systemUserFlag);


	const state = reactive({

		isauthentication: false,


	});
	onShow(() => {

		plugin.getRetailInfo({
			success: (value) => {
				state.isauthentication = value.status

				const {
					code,
					data
				} = AuthUtil.authentication({
					"isEnableUsePlugin": value.data.isEnableUsePlugin,
					"isGrantRetailInfo": value.data.isGrantRetailInfo,
					"phone": value.data.phone,
					"storeType": value.data.storeType,
					"storeAddress": value.data.storeAddress,
					"businessName": value.data.businessName,
					"businessId": value.data.businessId,
					"managerName": value.data.managerName,
					"openid": value.data.openid

				});
			}
		})
		sheep.$store('user').updateUserData();
	});

	onPullDownRefresh(() => {
		sheep.$store('user').updateUserData();
		setTimeout(function() {
			uni.stopPullDownRefresh();
		}, 800);
	});

	onPageScroll(() => {});
</script>

<style></style>